package cn.edu.zime.bigdata.aspects;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class AspectTest {
    //@Pointcut("execution(* cn.edu.zime.bigdata.controller.*.*(..))")
    @Pointcut("@annotation(cn.edu.zime.bigdata.anotations.AnatationTest)")
    public void check(){}

    @Before("check()")
    public void before(JoinPoint joinPoint){
        System.out.println("-----starting"+joinPoint.toString());
    }
    @After("check()")
    public void after(JoinPoint joinPoint){
        System.out.println("-----ended"+joinPoint.getSignature());
    }
    @AfterReturning(value = "check()", returning = "result")
    public void afterReturning(JoinPoint joinPoint, Object result){
        System.out.println(joinPoint+ "return result is:" + result);
    }
    @AfterThrowing(value = "check()", throwing = "e")
    public void afterThrowing(JoinPoint joinPoint, Exception e){
        System.out.println(joinPoint + "throw exception:" + e.getMessage());
    }
}
